class Solution {
    public int majorityElement(int[] nums) {
        int leader = nums[0];
        int count = 1;
        for(int i = 0;inums.length;i++) {
           if(nums[i] == leader) {
               count++;
           }else {
               count--;
           }
           if(0 == count) {
               leader = nums[i];
               count = 1;
           }
        }
        return leader;
    }
}